package io.rong.app.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.yunshipei.adapter.SeekContactAdapter;
import com.yunshipei.adapter.SeekFriendPinYinComparator;
import com.yunshipei.base.BaseActivity;
import com.yunshipei.common.net.HttpMethods;
import com.yunshipei.common.wedigt.YspTitleBar;
import com.yunshipei.db.DatabaseUtil;
import com.yunshipei.base.BaseSubscriberAdapter;
import com.yunshipei.common.Globals;
import com.yunshipei.model.UserInfo;
import com.yunshipei.core.utils.NetUtils;
import com.yunshipei.enterplorer.R;
import com.yunshipei.model.SortModel;
import com.yunshipei.model.YspEvent;
import com.yunshipei.ui.activity.GroupListActivity;
import com.yunshipei.ui.dialog.CreateGroupDialog;
import com.yunshipei.ui.dialog.DialogHelper;
import com.yunshipei.ui.view.SideBar;
import com.yunshipei.ui.view.SideBar.OnTouchingLetterChangedListener;
import com.yunshipei.utils.CharacterParser;
import com.yunshipei.utils.ClearEditText;
import com.yunshipei.utils.StringUtil;
import com.yunshipei.utils.ToastUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

import io.rong.app.DemoContext;
import io.rong.app.model.GroupCreateInfo;
import io.rong.app.model.SortModelHaveCheck;
import io.rong.app.ui.WinToast;
import io.rong.app.utils.StringUtilSub;
import io.rong.eventbus.EventBus;
import io.rong.imkit.RongIM;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Group;

/**
 * Created by Bob on 2015/3/18.
 */
public class FriendListActivity extends BaseActivity implements OnClickListener {
    public static final String FROMHERE = "from";
    public static final String STATE = "state";
    public static final String NEWUUIDS = "newUuids";
    public static final String NEWAMOUNT = "newAmount";
    private boolean status = true;
    private int state;
    private int newAmount = 0;
    private Dialog mDialog;
    private String uuid;
    private String uuids, NewMembers;
    private String gid = "";
    private DatabaseUtil dbUtil;
    private ListView sortListView;
    private SideBar sideBar;
    private TextView dialog;
    private SeekContactAdapter adapter;
    private List<UserInfo> list;
    private ClearEditText mClearEditText;
    private TextView defineButton;
    private List<SortModelHaveCheck> sortedList;
    private YspTitleBar mTitleBar;
    private CharacterParser characterParser;
    private List<SortModelHaveCheck> sourceDateList;
    private TextView emptyContent = null;
    private SharedPreferences mySharedPreferences;
    private SeekFriendPinYinComparator seekFriendPinYinComparator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.de_ui_list_test);
        mySharedPreferences = getSharedPreferences("ysp_rongCloud", Activity.MODE_PRIVATE);
        uuid = mySharedPreferences.getString("uuid", "");
        initView();
        initData();
    }

    private void initView() {
        emptyContent = (TextView) findViewById(R.id.empty_content);
        mClearEditText = (ClearEditText) findViewById(R.id.filter_edit);
        mTitleBar = (YspTitleBar) findViewById(R.id.title_bar);
        mTitleBar.setTitle(getResources().getString(R.string.main_group));
        //确定
        defineButton = (TextView) mTitleBar.findViewById(R.id.extras_title);
        defineButton.setVisibility(View.VISIBLE);
        defineButton.setOnClickListener(this);
        sideBar = (SideBar) findViewById(R.id.sidrbar1);
        dialog = (TextView) findViewById(R.id.dialog1);
        sideBar.setTextView(dialog);
        sortListView = (ListView) findViewById(R.id.country_lvcountry);
        mClearEditText = (ClearEditText) findViewById(R.id.filter_edit);
    }

    private void initData() {
        characterParser = CharacterParser.getInstance();
        seekFriendPinYinComparator = new SeekFriendPinYinComparator();
        dbUtil = new DatabaseUtil();
        Bundle bundle = getIntent().getBundleExtra(FROMHERE);
        state = bundle.getInt(STATE);
        uuids = getIntent().getStringExtra("uuids");
        gid = getIntent().getStringExtra("gid");
        list = new ArrayList<UserInfo>();
        list = dbUtil.queryAll();
        removeUserIsAdmin(list);
        list = new CopyOnWriteArrayList<>(list);
        filterData(state);
        //根据a-z进行排序源数据
        Collections.sort(sourceDateList, seekFriendPinYinComparator);
        adapter = new SeekContactAdapter(this, sourceDateList);
        sortListView.setAdapter(adapter);
        sortListView.setEmptyView(emptyContent);
        sortListView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                itemClick(parent, view, position, id);
            }
        });
        setSideBarEvent();
        setSearchViewEvent();
        if (sourceDateList.size() == 0) {
            emptyContent.setText("暂无数据");
        }
    }

    private void filterData(int state) {
        Iterator it = list.iterator();
        switch (state) {
            case 2:
                while (it.hasNext()) {          //去除已经在群中的人
                    UserInfo userInfo = (UserInfo) it.next();
                    if (StringUtilSub.judgeExist(userInfo.getUuid(), uuids)) {
                        list.remove(userInfo);
                    }
                }
                setFillData();
                break;
            case 4:         //短信群发
                while (it.hasNext()) {
                    UserInfo userInfo = (UserInfo) it.next();
                    if (userInfo != null && userInfo.getUuid().equals(mySharedPreferences.getString("uuid", ""))) {
                        list.remove(userInfo);
                        break;
                    }
                }
                setFillData();
                mTitleBar.setTitle(getResources().getString(R.string.add_contacts));
                break;
            case 1:         //创建群
                setFillData();
                break;
            case 3:
                list.clear();
                UserInfo userInfo = null;
                try {
                    JSONArray jsonArray = new JSONArray(uuids);
                    for (int j = 0; j < jsonArray.length(); j++) {
                        userInfo = dbUtil.queryUserInfoByid(jsonArray.optString(j));
                        if (userInfo != null && !userInfo.getUuid().equals(uuid)) {
                            list.add(userInfo);
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                sourceDateList = filledData(list);
                defineButton.setText("删除(" + getAllCheckedUserInfo().size() + ")");
                break;
            default:
                break;
        }
    }

    private void setFillData() {
        sourceDateList = filledData(list);
        setMeWithTrue(sourceDateList, mySharedPreferences.getString("uuid", ""));
        defineButton.setText("确认(" + getAllCheckedUserInfo().size() + ")");
    }

    // 设置右侧触摸监听
    private void setSideBarEvent() {
        sideBar.setOnTouchingLetterChangedListener(new OnTouchingLetterChangedListener() {
            @Override
            public void onTouchingLetterChanged(String s) {
                // 该字母首次出现的位置
                int position = adapter.getPositionForSection(s.charAt(0));
                if (position != -1) {
                    sortListView.setSelection(position);
                }
            }
        });
    }

    // 根据输入框输入值的改变来过滤搜索
    private void setSearchViewEvent() {
        mClearEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // 当输入框里面的值为空，更新为原来的列表，否则为过滤数据列表
                filterData(s.toString());
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });
    }

    private void itemClick(AdapterView<?> parent, View view, int position, long id) {
        if (state == 4 && getAllCheckedUserInfo().size() > 9) {
            DialogHelper.showCheckMassTextDialog(FriendListActivity.this);
            return;
        }
        if (!status) {
            CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkBox1);
            if (sortedList.get(position).getStatus()) {
                if (!sortedList.get(position).getSortModel().getUserInfo().isSelecteState()) {
                    sortedList.get(position).setStatus(false);
                    checkBox.setChecked(false);
                }
            } else {
                sortedList.get(position).setStatus(true);
                checkBox.setChecked(true);
            }
        } else {
            CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkBox1);
            if (sourceDateList.get(position).getStatus()) {
                if (!sourceDateList.get(position).getSortModel().getUserInfo().isSelecteState()) {
                    sourceDateList.get(position).setStatus(false);
                    checkBox.setChecked(false);
                }
            } else {
                sourceDateList.get(position).setStatus(true);
                checkBox.setChecked(true);
            }
        }
        if (state == 3) {
            defineButton.setText("删除(" + getAllCheckedUserInfo().size() + ")");
        } else {
            defineButton.setText("确认(" + getAllCheckedUserInfo().size() + ")");
        }
    }

    /**
     * 创建群
     */
    private void createGroupEvent() {
        if (getAllCheckedUserInfo().size() != 0) {
            List<SortModelHaveCheck> list = getAllCheckedUserInfo();
            if (list.size() == 1 &&
                    list.get(0).getSortModel().getUserInfo().getUuid().equals(uuid)) {
                showToast(getResources().getString(R.string.group_member_not_only_me));
            } else if (list.size() == 2) {
                for (int i = 0; i < list.size(); i++) {
                    //开启单聊
                    if (!list.get(i).getSortModel().getUserInfo().getUuid().equals(uuid)) {
                        startConversation(list.get(i).getSortModel().getUserInfo().getUuid());
                        finish();
                        break;
                    }
                }
            } else if (getAllCheckedUserInfo().size() <= Globals.GROUPMAX) {
                //创建群组
                createGroup();
            } else {
                showToast("群组成员上限为" + Globals.GROUPMAX + "人");
            }
        } else {
            showToast(getResources().getString(R.string.group_member_not_empty));
        }
    }

    private void defineClick(View view) {
        if (state == 1) {
            createGroupEvent();
        } else if (state == 2 && getAllCheckedUserInfo().size() <= Globals.GROUPMAX) {
            //添加成员到群组
            addMemberToGroup();
        } else if (state == 3) {
            final String oldAndNewUuids[] = StringUtilSub.splitString(getAllCheckedUserInfo()).split(",");
            if (oldAndNewUuids.length <= 1 && "".equals(oldAndNewUuids[0])) {
                showToast("请选择要删除成员");
            } else {
                DialogHelper.deleteGroupMemberDialog(FriendListActivity.this, "你确认要删除已选择的" + getAllCheckedUserInfo().size() + "位群成员？", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                        showRoundProcessDialog(FriendListActivity.this, R.layout.loading_process_dialog_anim);
                        quitGroup(false, oldAndNewUuids, new DeleteGruopSubscriber(oldAndNewUuids));
                    }
                });
            }
        } else if (state == 4) {
            //群发短信
            List<SortModelHaveCheck> list = getAllCheckedUserInfo();
            StringBuffer stringBuffer = new StringBuffer();
            if (list == null)
                return;
            for (SortModelHaveCheck smhc : list) {
                stringBuffer.append(smhc.getSortModel().getUserInfo().getTel());
                stringBuffer.append(";");
            }
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.putExtra("address", stringBuffer.toString());
            intent.setType("vnd.android-dir/mms-sms");
            startActivity(intent);
            finish();

        } else {
            showToast("群组成员上限为" + Globals.GROUPMAX + "人");
        }
    }

    /**
     * 根据输入框中的值来过滤数据并更新ListView
     *
     * @param filterStr
     */
    private void filterData(String filterStr) {
        filterStr = filterStr.toUpperCase();
        List<SortModelHaveCheck> filterDateList = new ArrayList<SortModelHaveCheck>();
        status = false;
        if (TextUtils.isEmpty(filterStr)) {
            filterDateList = sourceDateList;
            status = true;
        } else {
            filterDateList.clear();
            for (SortModelHaveCheck sortModelHaveCheck : sourceDateList) {
                String name = sortModelHaveCheck.getSortModel().getUserInfo().getName().toUpperCase();
                String phone = sortModelHaveCheck.getSortModel().getUserInfo().getTel();
                String position = sortModelHaveCheck.getSortModel().getUserInfo().getPosition();
                if (characterParser.getSelling(name).toLowerCase().indexOf(filterStr.toLowerCase()) != -1 || compare(name, filterStr) || compare(phone, filterStr) || compare(position, filterStr)) {
                    filterDateList.add(sortModelHaveCheck);
                }
            }
        }
        // 根据a-z进行排序
        Collections.sort(filterDateList, seekFriendPinYinComparator);
        sortedList = filterDateList;
        if (sortedList.size() == 0) {
            emptyContent.setText("没有匹配结果");
        }
        adapter.updateListView(sortedList);
    }

    private boolean compare(String str1, String str2) {
        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();
        if (str1.indexOf(str2.toString()) != -1 || characterParser.getSelling(str1).startsWith(str2.toString())) {
            return true;
        }
        return false;
    }

    /**
     * 为ListView填充数据
     *
     * @return
     */
    private List<SortModelHaveCheck> filledData(List<UserInfo> listA) {
        List<SortModelHaveCheck> filterDateList = new ArrayList<SortModelHaveCheck>();
        int length = listA.size();
        for (int i = 0; i < length; i++) {
            SortModelHaveCheck sortModelHaveCheck = new SortModelHaveCheck();
            SortModel sortModel = new SortModel();
            UserInfo userInfo = new UserInfo();
            userInfo = listA.get(i);
            userInfo.setSelecteState(false);
            sortModel.setUserInfo(userInfo);
            sortModelHaveCheck.setSortModel(sortModel);
            sortModelHaveCheck.setStatus(false);
            String pinyin = characterParser.getSelling(listA.get(i).getName());
            String sortString = pinyin.substring(0, 1).toUpperCase();
            // 正则表达式，判断首字母是否是英文字母
            if (sortString.matches("[A-Z]")) {
                sortModelHaveCheck.getSortModel().setSortLetters(sortString.toUpperCase());
            } else {
                sortModelHaveCheck.getSortModel().setSortLetters("#");
            }
            filterDateList.add(sortModelHaveCheck);
        }
        return filterDateList;
    }

    /**
     * 计算已经被选中的人数
     *
     * @return
     */
    public List<SortModelHaveCheck> getAllCheckedUserInfo() {
        List<SortModelHaveCheck> result = new ArrayList<SortModelHaveCheck>();
        for (SortModelHaveCheck smhc : sourceDateList) {
            if (smhc.getStatus()) {
                result.add(smhc);
            }
        }
        return result;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.extras_title:
                defineClick(v);
                break;
            default:
                break;

        }
    }

    public class NewGroupInfoSubscriber extends BaseSubscriberAdapter<JSONObject> {

        @Override
        public void onError(String errorMessage) {
            closeProcessDialog();
        }

        @Override
        public void onNext(JSONObject jsonObject) {
            closeProcessDialog();
            GroupCreateInfo groupCreateInfo = new GroupCreateInfo();
            groupCreateInfo = SqlToObj(jsonObject, groupCreateInfo);
            if (DemoContext.getInstance(FriendListActivity.this) != null) {
                DemoContext.getInstance(FriendListActivity.this).addGroupCreateInfo(groupCreateInfo);
                Map<String, Group> map = new HashMap<>();
                map.put(groupCreateInfo.getId(), new Group(groupCreateInfo.getId(), groupCreateInfo.getName(), null));
                DemoContext.getInstance(FriendListActivity.this).addInfoGroupMap(map);
                if (groupCreateInfo != null) {
                    //进入群聊界面
                    RongIM.getInstance().startGroupChat(FriendListActivity.this, groupCreateInfo.getId(), groupCreateInfo.getName());
                }
            }
            //插入数据库
            insertNewGroupInfoToSQL(groupCreateInfo);
            finish();
        }

    }

    public class AddGroupMemberSubscriber extends BaseSubscriberAdapter<JSONObject> {

        @Override
        public void onNext(JSONObject jsonObject) {
            closeProcessDialog();
            try {
                if (jsonObject.getInt("status") == 1) {
                    Intent intent = new Intent();
                    intent.putExtra(NEWAMOUNT, "" + newAmount);
                    intent.putExtra(NEWUUIDS, NewMembers);
                    setResult(RESULT_OK, intent);
                    finish();
                    showToast("添加成功");
                } else {
                    showToast("成员添加失败,请重新添加");
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(String errorMessage) {
            closeProcessDialog();
        }
    }

    public GroupCreateInfo SqlToObj(JSONObject result, GroupCreateInfo groupCreateInfo) {
        GroupCreateInfo group = null;
        group = groupCreateInfo;
        try {
            JSONObject messageJsonObject = new JSONObject(result.getString("data"));
            group.setId(messageJsonObject.getString("id"));
            group.setName(messageJsonObject.getString("name"));
            group.setIntroduce(messageJsonObject.getString("introduce"));
            group.setNumber(messageJsonObject.getInt("number"));
            group.setMax_number(messageJsonObject.getInt("max_number"));
            group.setCreate_user_id(messageJsonObject.getString("create_user_id"));
            group.setCreate_dateTime(messageJsonObject.getString("create_dateTime"));
            group.setPortraitUri(messageJsonObject.getString("avatar"));
            group.setGourpMembers(messageJsonObject.getString("groupMembers"));

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return group;
    }

    public void insertNewGroupInfoToSQL(GroupCreateInfo group) {
        //数据库操作
        DatabaseUtil databaseUtil = new DatabaseUtil();
        if (!databaseUtil.insertGroup(group)) {
            showToast("本地创建群组失败！！！");
        }
    }

    public void skip() {
        Intent intent = new Intent();
        intent.setClass(FriendListActivity.this, GroupListActivity.class);
        startActivity(intent);
        finish();
    }

    /**
     * LoadingDialog
     *
     * @param mContext
     * @param layout
     */
    public void showRoundProcessDialog(Context mContext, int layout) {
        DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() {

            @Override
            public boolean onKey(DialogInterface dialog, int keyCode,
                                 KeyEvent event) {
                // TODO Auto-generated method stub
                if (keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_SEARCH) {
                    return true;
                }
                return false;
            }
        };
        mDialog = new AlertDialog.Builder(mContext).create();
        mDialog.setOnKeyListener(keyListener);
        mDialog.show();
        View view = LayoutInflater.from(mContext).inflate(layout, null);
        mDialog.getWindow().setContentView(view);
    }

    public void closeProcessDialog() {
        mDialog.dismiss();
    }

    //将自己设置为选中状态
    public void setMeWithTrue(List<SortModelHaveCheck> list, String uuid) {
        for (SortModelHaveCheck sortObj : list) {
            String sort_uuid = sortObj.getSortModel().getUserInfo().getUuid();
            if (!StringUtil.isEmpty(sort_uuid) && sort_uuid.equals(uuid)) {
                sortObj.setStatus(true);
                sortObj.getSortModel().getUserInfo().setSelecteState(true);
            }
        }
    }

    private void createGroup() {
        final CreateGroupDialog createGroupDialog = new CreateGroupDialog(FriendListActivity.this,
                R.style.cike_alert_dialog);
        createGroupDialog.setRefrimOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String groupNameString = createGroupDialog.getNameEditTextValues();
                if (TextUtils.isEmpty(groupNameString)) {
                    showToast(getResources().getString(R.string.group_name_empty));
                } else {
                    if (!NetUtils.isNetworkAvailable(FriendListActivity.this)) {
                        ToastUtils.showToast(R.string.net_no_connect);
                        return;
                    }
                    Map<String, String> map = new HashMap<String, String>();
                    String groupName = createGroupDialog.getNameEditTextValues();
                    map.put("id", uuid);
                    map.put("name", groupName);
                    map.put("cids", StringUtilSub.splitString(getAllCheckedUserInfo()));
                    createGroupDialog.cancel();
                    showRoundProcessDialog(FriendListActivity.this, R.layout.loading_process_dialog_anim);
                    HttpMethods.getInstance().addIMGroupMembers(uuid, groupName, StringUtilSub.splitString(getAllCheckedUserInfo()), new NewGroupInfoSubscriber());
                }
            }
        });
        createGroupDialog.setQuitOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                createGroupDialog.cancel();
            }
        });
        createGroupDialog.show();
    }

    private void addMemberToGroup() {
        Intent intent = getIntent();
        String gid = intent.getStringExtra("gid");
        String oldAndNewUuids[] = StringUtilSub.splitString(getAllCheckedUserInfo()).split(",");
        List<String> list = Arrays.asList(oldAndNewUuids);
        newAmount = list.size();
        StringBuffer stringBuffer = new StringBuffer();
        for (String str : list) {
            if (!StringUtilSub.judgeExist(str, uuids) && !TextUtils.isEmpty(str)) {
                if (stringBuffer.length() == 0)
                    stringBuffer.append(str);
                else
                    stringBuffer.append("," + str);
            }
        }
        NewMembers = stringBuffer.toString();
        if (TextUtils.isEmpty(NewMembers)) {
            showToast("请添加新成员");
        } else {
            showRoundProcessDialog(FriendListActivity.this, R.layout.loading_process_dialog_anim);
            HttpMethods.getInstance().setupIMGroup(NewMembers, gid, new AddGroupMemberSubscriber());
        }
    }

    private void startConversation(String targetId) {
        RongIM.getInstance().startConversation(this, Conversation.ConversationType.PRIVATE, targetId, "聊天标题");
    }

    private void showToast(String toastContext) {
        Toast.makeText(FriendListActivity.this, toastContext, Toast.LENGTH_SHORT).show();
    }

    public void quitGroup(boolean isActive, String[] quitUuid, BaseSubscriberAdapter<JSONObject> baseSubscriber) {
        if (DemoContext.getInstance(FriendListActivity.this) != null) {
            HttpMethods.getInstance().newExitIMGroup(isActive, mySharedPreferences.getString("companyId", ""), quitUuid, gid, baseSubscriber);
        }
    }

    private class DeleteGruopSubscriber extends BaseSubscriberAdapter<JSONObject> {

        String[] deleteIds;

        public DeleteGruopSubscriber(String[] strArray) {
            this.deleteIds = strArray;
        }

        @Override
        public void onNext(JSONObject jsonObject) {
            closeProcessDialog();
            try {
                if (jsonObject.getInt("status") == 1) {
                    WinToast.toast(FriendListActivity.this, " 删除成功 ");
                    if (TextUtils.isEmpty(uuids))
                        return;
                    for (int i = 0; deleteIds.length > 0 && i < deleteIds.length; i++) {
                        uuids = StringUtilSub.removeOldMemberUuid(uuids, deleteIds[i]);
                    }
                    EventBus.getDefault().post(new YspEvent.DeleteGroupMember(uuids, gid));         //通知群详情更新信息
                    DemoContext.getInstance(FriendListActivity.this).updateGroupInfoById(gid, uuids);
                    EventBus.getDefault().post(1);
                    finish();
                } else if (jsonObject.getInt("status") == 0) {
                    WinToast.toast(FriendListActivity.this, jsonObject.getString("message"));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

    }

    private List<UserInfo> removeUserIsAdmin(List<UserInfo> list) {
        Iterator<UserInfo> iterator = list.iterator();
        while (iterator.hasNext()) {
            if (Boolean.parseBoolean(iterator.next().getIsAdmin())) {
                iterator.remove();
            }
        }
        return list;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
